package com.xing.oss.controller;

import com.xing.commonutils.R;
import com.xing.oss.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * Oss控制层
 *  jtazaddddd
 * @author: xingfuhao
 * @create: 2022-01-17 23:54
 */

@RestController  //交给Spring管理，返回json数据
@RequestMapping("/eduoss/fileoss")
@CrossOrigin //解决跨域问题
public class OssController {

    @Autowired
    private  OssService ossService;

    @PostMapping
    public R uploadOssFile(MultipartFile file){
       //获取上传文件，MultipartFile
       //返回上传到Oss的路径
       String url= ossService.uploadFileAvatar(file);
       return R.ok().data("url",url);
    }

    @PostMapping("/a")
    public R a(){
        System.out.println("====a");
        return R.ok();
    }
}
